<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample for retrieving TPRS User ID</title>

<!-- 步驟一、在使用TPRS推薦API的頁面上引用 tprs.js -->
<script type="text/javascript" src="js/tprs-2.1.js"></script> 

<script>
function clickOnItem(itemId){
	//步驟二、在呼叫TPRS API時,若需要帶入使用者ID,
	//        則透過get_TprsUserId()方法取得cookie中存放的 TPRS user id
	var tprsUserId = get_TprsUserId();
	
	//步驟三、進行空值處理,此部分請客戶自行處理
	/*
	if(tprsUserId == '' || tprsUserId == 'undefined' || tprsUserId == 'null'){
		tprsUserId = '<%=session.getId() %>';
	}
	*/
	alert('send click log for user/item : ' + tprsUserId + '/' + itemId);
}
</script>

</head>
<body>


<H1> This sample shows how to get the TPRS User ID from tprs.js</H1>

This HTML file could not be executed on your local file system, please run it from a web server. <br/>
無法在local端用瀏覽器打開檔案方式執行,請放置於web server上測試<br/>
<br/>
<a href="javascript:clickOnItem('itemid-001');">Click me to simulate sending a click log</a>

</body>
</html>